|
|
|
|
|
|
|
Exit Sub
'
LocalErr:
strMsg = strMsg & "<err>"
Resume Next
'
End Sub |
|
|
|
|
|
|
|
|
The code in Listing 9.24 performs the basic tasks. Create a database and build two tables with two fields each. Construct primary key indexes for both tables. Then create the relationship object. |
|
|
|
|
|
|
|
|
Save and run the project. When you click the Relation command button, the program creates all the data objects, and then displays the resulting Relation object on the form. Compare your results to the screen in Figure 9.24. |
|
|
|
|
|
|
|
|
Figure 9.24.
Viewing the results of a Relation object. |
|
|
|
|
|
|
|
|
Notice that you added an attribute to make this relationship enforce cascading updates, which means that any time a value is changed in the lookup table, all the corresponding values in the foreign table are updated automatically too. You can also set delete cascades. If the value is deleted from the lookup table, all corresponding records in the foreign table are deleted. |
|
|
|
|
|
|
|
|
In today's lesson, you learned the features and functions of Visual Basic Microsoft Jet data access objects and ODBCDirect access objects. These objects are used within Visual Basic code to create and maintain workspaces, databases, tables, fields, indexes, queries, and relations. You learned the properties, methods, and collections of each object. You also learned how to use Visual Basic code to inspect the values in the properties, and how to use the methods to perform basic database operations. |
|
|
|
|
|